﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Net;
using System.Net.Sockets;
namespace WuHouCiClient
{
    class Program
    {
        static void Main(string[] args)
        {
            start_link s = start_link.getInstance();
            s.conect(1000,1000);
            //int index = 1;
            //flag:TcpClient tcpc = CNet.createConnect("127.0.0.1", 6001);
            //if (tcpc == null)
            //{
            //    Console.WriteLine("connect error,reconnect\n");
            //    goto flag;
                
            //}

            //CNet.sendPakage(Encoding.UTF8.GetBytes("send !!"), tcpc);
            //Console.WriteLine("send package-->"+index);
            //int readnum = 0;
            //byte[] message = CNet.recvPackage(ref readnum, tcpc);
            //Console.WriteLine("read package:");
            //Console.ReadKey();
            //index++;
            //goto flag;
            //////////////////KMP算法测试代码////////////////////
            //string str = "123412341234123412341223412345";
            //string str2 = "1";
            //byte[] b = Encoding.UTF8.GetBytes(str);
            //byte[] b2 = Encoding.UTF8.GetBytes(str2);
            //foreach(byte bi in b)
            //{
            //    Console.WriteLine(b);
            //}
            //foreach (byte bi in b2)
            //{
            //    Console.WriteLine(b2);
            //}
            //    Console.WriteLine("next is index -----------------");
            //int index = CProtocol.KMP(b,b2);
            //Console.WriteLine(index);
            //Console.ReadKey();
            /////////////////////////////////////////////////////////
            //测试protocol类。
            //CProtocol cp = CProtocol.getInstance();
            //data d = new data();
            //d.id = 101;
            //d.dataInfo = new byte[100];
            //for (int i = 0; i < 100; i++)
            //{
            //    d.dataInfo[i] = (byte)(i);
            //}
            //cp.sendToServer(d);
            //byte[] b = cp.sendBuffer.ToArray();
            //for (int i = 0; i < b.Length; i++)
            //{
            //    Console.WriteLine(b[i]);
            //}
            //cp.pushRecvBuffer(b);

            //Console.ReadKey();
            //////////////////////////////////////////////
            //Int32 转 byte[4], byte[4] 转 Int32 测试
            //int r = -101;
            //byte[] d = CProtocol.intToByte4(r);
            //for (int i = 0; i < 4; i++)
            //{
            //    Console.WriteLine(d[i]);
            //}
            //Console.WriteLine("---------------");
            //r = CProtocol.byte4ToInt(d);
            //Console.WriteLine(r);
            //Console.ReadKey();
        }
    }
}
